from  .componentManager import componentManager as manager
import  logging
class TBaseComp:
    def __init__(self):
        self.componentKey = ""
        self.manager = manager
        self.settings={}
        self.logger = None
        self.handlers={}

    def regist(self):
        try:
            ck = self.componentKey
            manager.components[ck] = self
            if 'components' in manager.settings.keys() and ck in manager.settings['components'].keys():
                self.settings = manager.settings['components'][ck]
        except Exception as er:
            print(er)
    def handler(self , action , params):
        res={}
        try:
            pass
        except Exception as er:
            print(er)
        return res
    def doOnSetSettings(self):
        print(self.componentKey , self.settings)
    def getLoggerPath(self):
        res = ""
        try:
            res = self.manager.setSettings['common']['logpath']+"/"+ self.componentKey+".txt"
        except Exception as er:
            print(er)
        return  res
